﻿<local:BaseWindow
    x:Class="LenovoLegionToolkit.WPF.Windows.Dashboard.GodModeSettingsWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:LenovoLegionToolkit.WPF.Controls"
    xmlns:godMode="clr-namespace:LenovoLegionToolkit.WPF.Controls.Dashboard.GodMode"
    xmlns:local="clr-namespace:LenovoLegionToolkit.WPF.Windows"
    xmlns:resources="clr-namespace:LenovoLegionToolkit.WPF.Resources"
    xmlns:utils="clr-namespace:LenovoLegionToolkit.WPF.Utils"
    xmlns:wpfui="http://schemas.lepo.co/wpfui/2022/xaml"
    Title="{x:Static resources:Resource.GodModeSettingsWindow_Title}"
    Width="800"
    Height="700"
    MinWidth="800"
    MinHeight="500"
    FlowDirection="{x:Static utils:LocalizationHelper.Direction}"
    ResizeMode="CanMinimize"
    ShowInTaskbar="False"
    WindowStartupLocation="CenterOwner">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <wpfui:TitleBar
            Grid.Row="0"
            CanMaximize="false"
            ShowMaximize="false"
            ShowMinimize="false"
            UseSnapLayout="false" />

        <Grid
            Grid.Row="0"
            Height="24"
            Margin="12,8,12,8">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <TextBlock
                Grid.Column="0"
                VerticalAlignment="Center"
                FontSize="12"
                IsHitTestVisible="False"
                Text="{x:Static resources:Resource.GodModeSettingsWindow_Title}" />

        </Grid>

        <controls:LoadableControl
            x:Name="_loader"
            Grid.Row="1"
            Margin="12,0,0,0"
            IndicatorVerticalAlignment="Center">
            <wpfui:DynamicScrollViewer>
                <StackPanel Margin="0,0,16,0">

                    <wpfui:InfoBar
                        x:Name="_vantageRunningWarningInfoBar"
                        Title="{x:Static resources:Resource.GodModeSettingsWindow_VantageWarning_Title}"
                        Margin="0,16,0,0"
                        IsClosable="False"
                        IsOpen="False"
                        Severity="Error" />

                    <wpfui:InfoBar
                        x:Name="_legionZoneRunningWarningInfoBar"
                        Title="{x:Static resources:Resource.GodModeSettingsWindow_LegionZoneWarning_Title}"
                        Margin="0,16,0,0"
                        IsClosable="False"
                        IsOpen="False"
                        Severity="Error" />

                    <TextBlock
                        Margin="0,16,0,24"
                        FontSize="24"
                        FontWeight="Medium"
                        Text="{x:Static resources:Resource.GodModeSettingsWindow_ActivePreset_Title}" />

                    <Grid Margin="0,0,0,16">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <ComboBox
                            x:Name="_presetsComboBox"
                            Grid.Column="0"
                            SelectionChanged="PresetsComboBox_SelectionChanged" />

                        <wpfui:Button
                            Grid.Column="1"
                            Margin="8,0,0,0"
                            VerticalAlignment="Stretch"
                            Click="EditPresetsButton_Click"
                            Icon="Edit24"
                            ToolTip="{x:Static resources:Resource.Edit}" />
                        <wpfui:Button
                            x:Name="_deletePresetsButton"
                            Grid.Column="2"
                            Margin="8,0,0,0"
                            VerticalAlignment="Stretch"
                            Click="DeletePresetsButton_Click"
                            Icon="Dismiss24"
                            ToolTip="{x:Static resources:Resource.Delete}" />
                        <wpfui:Button
                            x:Name="_addPresetsButton"
                            Grid.Column="3"
                            Margin="8,0,0,0"
                            VerticalAlignment="Stretch"
                            Appearance="Primary"
                            Click="AddPresetsButton_Click"
                            Content="{x:Static resources:Resource.Add}"
                            Icon="Add24" />
                    </Grid>

                    <TextBlock
                        x:Name="_cpuSectionTitle"
                        Margin="0,16,0,24"
                        FontSize="24"
                        FontWeight="Medium"
                        Text="{x:Static resources:Resource.GodModeSettingsWindow_CPU_Title}" />

                    <godMode:GodModeValueControl
                        x:Name="_cpuLongTermPowerLimitControl"
                        Title="{x:Static resources:Resource.GodModeSettingsWindow_CPU_LongTermPL}"
                        Margin="0,0,0,8"
                        Description="{x:Static resources:Resource.GodModeSettingsWindow_CPU_LongTermPL_Description}"
                        Unit="W" />

                    <godMode:GodModeValueControl
                        x:Name="_cpuShortTermPowerLimitControl"
                        Title="{x:Static resources:Resource.GodModeSettingsWindow_CPU_ShortTermPL}"
                        Margin="0,0,0,8"
                        Description="{x:Static resources:Resource.GodModeSettingsWindow_CPU_ShortTermPL_Description}"
                        Unit="W" />

                    <godMode:GodModeValueControl
                        x:Name="_cpuPeakPowerLimitControl"
                        Title="{x:Static resources:Resource.GodModeSettingsWindow_CPU_PeakPL}"
                        Margin="0,0,0,8"
                        Description="{x:Static resources:Resource.GodModeSettingsWindow_CPU_PeakPL_Description}"
                        Unit="W" />

                    <godMode:GodModeValueControl
                        x:Name="_cpuCrossLoadingLimitControl"
                        Title="{x:Static resources:Resource.GodModeSettingsWindow_CPU_CrossLoading}"
                        Margin="0,0,0,8"
                        Description="{x:Static resources:Resource.GodModeSettingsWindow_CPU_CrossLoading_Description}"
                        Unit="W" />

                    <godMode:GodModeValueControl
                        x:Name="_cpuPL1TauControl"
                        Title="{x:Static resources:Resource.GodModeSettingsWindow_CPU_PL1Tau}"
                        Margin="0,0,0,8"
                        Description="{x:Static resources:Resource.GodModeSettingsWindow_CPU_PL1Tau_Description}"
                        Unit="s" />

                    <godMode:GodModeValueControl
                        x:Name="_apuSPPTPowerLimitControl"
                        Title="{x:Static resources:Resource.GodModeSettingsWindow_CPU_APUsPPT_PL}"
                        Margin="0,0,0,8"
                        Description="{x:Static resources:Resource.GodModeSettingsWindow_CPU_APUsPPT_PL_Description}"
                        Unit="W" />

                    <godMode:GodModeValueControl
                        x:Name="_cpuTemperatureLimitControl"
                        Title="{x:Static resources:Resource.GodModeSettingsWindow_CPU_TempLimit}"
                        Margin="0,0,0,8"
                        Description="{x:Static resources:Resource.GodModeSettingsWindow_CPU_TempLimit_Description}"
                        Unit="°C" />

                    <TextBlock
                        x:Name="_gpuSectionTitle"
                        Margin="0,16,0,24"
                        FontSize="24"
                        FontWeight="Medium"
                        Text="{x:Static resources:Resource.GodModeSettingsWindow_GPU_Title}" />

                    <godMode:GodModeValueControl
                        x:Name="_gpuPowerBoostControl"
                        Title="{x:Static resources:Resource.GodModeSettingsWindow_GPU_DynamicBoost}"
                        Margin="0,0,0,8"
                        Description="{x:Static resources:Resource.GodModeSettingsWindow_GPU_DynamicBoost_Description}"
                        Unit="W" />

                    <godMode:GodModeValueControl
                        x:Name="_gpuConfigurableTGPControl"
                        Title="{x:Static resources:Resource.GodModeSettingsWindow_GPU_CTGP}"
                        Margin="0,0,0,8"
                        Description="{x:Static resources:Resource.GodModeSettingsWindow_GPU_CTGP_Description}"
                        Unit="W" />

                    <godMode:GodModeValueControl
                        x:Name="_gpuTemperatureLimitControl"
                        Title="{x:Static resources:Resource.GodModeSettingsWindow_GPU_TempLimit}"
                        Margin="0,0,0,8"
                        Description="{x:Static resources:Resource.GodModeSettingsWindow_GPU_TempLimit_Description}"
                        Unit="°C" />

                    <godMode:GodModeValueControl
                        x:Name="_gpuTotalProcessingPowerTargetOnAcOffsetFromBaselineControl"
                        Title="{x:Static resources:Resource.GodModeSettingsWindow_GPU_TotalProcessingPowerTargetOnAcOffsetFromBaselineControl}"
                        Margin="0,0,0,8"
                        Description="{x:Static resources:Resource.GodModeSettingsWindow_GPU_TotalProcessingPowerTargetOnAcOffsetFromBaselineControl_Description}"
                        Unit="W" />

                    <godMode:GodModeValueControl
                        x:Name="_gpuToCpuDynamicBoostControl"
                        Title="{x:Static resources:Resource.GodModeSettingsWindow_GPU_ToCpuDynamicBoostControl}"
                        Margin="0,0,0,8"
                        Description="{x:Static resources:Resource.GodModeSettingsWindow_GPU_ToCpuDynamicBoostControl_Description}"
                        Unit="W" />

                    <TextBlock
                        x:Name="_fanSectionTitle"
                        Margin="0,16,0,24"
                        FontSize="24"
                        FontWeight="Medium"
                        Text="{x:Static resources:Resource.GodModeSettingsWindow_Fans_Title}" />

                    <wpfui:CardControl x:Name="_fanCurveCardControl" Margin="0,0,0,8">
                        <wpfui:CardControl.Header>
                            <StackPanel>
                                <controls:CardHeaderControl Title="{x:Static resources:Resource.GodModeSettingsWindow_Fans_Curve_Title}" Subtitle="{x:Static resources:Resource.GodModeSettingsWindow_Fans_Curve_Message}" />
                                <controls:FanCurveControl
                                    x:Name="_fanCurveControl"
                                    MaxWidth="700"
                                    Margin="0,32,0,0" />
                                <wpfui:Button
                                    MinWidth="120"
                                    HorizontalAlignment="Right"
                                    Click="DefaultFanCurve_Click"
                                    Content="{x:Static resources:Resource.Default}"
                                    Icon="ArrowClockwise24" />
                            </StackPanel>
                        </wpfui:CardControl.Header>
                    </wpfui:CardControl>

                    <wpfui:CardControl x:Name="_fanFullSpeedCardControl" Margin="0,0,0,8">
                        <wpfui:CardControl.Header>
                            <controls:CardHeaderControl Title="{x:Static resources:Resource.GodModeSettingsWindow_Fans_Max_Title}" Subtitle="{x:Static resources:Resource.GodModeSettingsWindow_Fans_Max_Message}" />
                        </wpfui:CardControl.Header>
                        <wpfui:ToggleSwitch
                            x:Name="_fanFullSpeedToggle"
                            Margin="0,0,0,8"
                            Click="FanFullSpeedToggle_Click" />
                    </wpfui:CardControl>

                    <TextBlock
                        x:Name="_advancedSectionTitle"
                        Margin="0,16,0,8"
                        FontSize="24"
                        FontWeight="Medium"
                        Text="{x:Static resources:Resource.GodModeSettingsWindow_Advanced_Title}" />

                    <TextBlock
                        x:Name="_advancedSectionMessage"
                        Margin="0,0,0,24"
                        FontSize="12"
                        Text="{x:Static resources:Resource.GodModeSettingsWindow_Advanced_Message}" />

                    <wpfui:CardControl x:Name="_maxValueOffsetCardControl" Margin="0,0,0,8">
                        <wpfui:CardControl.Header>
                            <controls:CardHeaderControl Title="{x:Static resources:Resource.GodModeSettingsWindow_Advanced_MaxOffset_Title}" Subtitle="{x:Static resources:Resource.GodModeSettingsWindow_Advanced_MaxOffset_Message}" />
                        </wpfui:CardControl.Header>
                        <wpfui:NumberBox
                            x:Name="_maxValueOffsetNumberBox"
                            Width="120"
                            Margin="32,0,0,0"
                            ClearButtonEnabled="False"
                            MaxDecimalPlaces="0"
                            Maximum="100"
                            Minimum="0" />
                    </wpfui:CardControl>

                    <wpfui:CardControl x:Name="_minValueOffsetCardControl" Margin="0,0,0,8">
                        <wpfui:CardControl.Header>
                            <controls:CardHeaderControl Title="{x:Static resources:Resource.GodModeSettingsWindow_Advanced_MinOffset_Title}" Subtitle="{x:Static resources:Resource.GodModeSettingsWindow_Advanced_MinOffset_Message}" />
                        </wpfui:CardControl.Header>
                        <wpfui:NumberBox
                            x:Name="_minValueOffsetNumberBox"
                            Width="120"
                            Margin="32,0,0,0"
                            ClearButtonEnabled="False"
                            MaxDecimalPlaces="0"
                            Maximum="0"
                            Minimum="-100" />
                    </wpfui:CardControl>

                </StackPanel>
            </wpfui:DynamicScrollViewer>
        </controls:LoadableControl>

        <Grid
            x:Name="_buttonsStackPanel"
            Grid.Row="2"
            Margin="12"
            Visibility="Collapsed">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <wpfui:Button
                x:Name="_loadButton"
                Grid.Column="0"
                MinWidth="120"
                Click="LoadButton_Click"
                Content="{x:Static resources:Resource.Load}"
                Icon="ChevronDown24" />

            <wpfui:Button
                Grid.Column="2"
                MinWidth="120"
                Click="SaveButton_Click"
                Content="{x:Static resources:Resource.Save}" />
            <wpfui:Button
                Grid.Column="3"
                MinWidth="120"
                Margin="12,0,0,0"
                Appearance="Primary"
                Click="SaveAndCloseButton_Click"
                Content="{x:Static resources:Resource.SaveAndClose}" />
        </Grid>

        <wpfui:Snackbar
            x:Name="_snackBar"
            Grid.Row="1"
            HorizontalAlignment="Center"
            CloseButtonEnabled="True"
            Icon="ErrorCircle24"
            Timeout="5000" />

    </Grid>
</local:BaseWindow>
